home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / M2PROTOS.ZIP / FIOASM.DEF < prev    next >
Encoding:
Modula Definition  |  1991-02-09  |  7.5 KB  |  213 lines

  1. (*%F _fdata *)
  2. (*# call(seg_name => null) *)
  3. (*%E *)
  4. (*# module(implementation=>off) *)
  5. (*# module(init_code=>off) *)
  6. (*# data(seg_name => null) *)
  7. (*# call(o_a_copy => off) *)
  8.  
  9. DEFINITION MODULE FioAsm;
  10.  
  11. (*
  12.  
  13. These routines are intended to replace low-level routines in JPI's FIO.MOD.
  14. FioAsm's routines are optimized through assembly language.
  15.  
  16.     -- Carl Neiburger
  17.        169 N. 25th St.
  18.        San Jose, Calif. 95116
  19.  
  20.        CompuServe No. 72336,2257
  21.  
  22. *)
  23.  
  24. TYPE
  25.   Handle = CARDINAL;
  26.   AccessType = (Input, Output, InputOutput);
  27.  
  28.   PathStr  = ARRAY[0..64] OF CHAR;
  29.   PathTail = ARRAY[0..12] OF CHAR;
  30.  
  31.   FileAttributes = (readonly,hidden,system,volume,directory,archive,ioerror);
  32.   FileAttr = SET OF FileAttributes;
  33.   DirEntry = RECORD
  34.                rsvd : ARRAY[0..20] OF SHORTCARD;
  35.                attr : FileAttr;
  36.                time : CARDINAL;
  37.                date : CARDINAL;
  38.                size : LONGCARD;
  39.                Name : PathTail;
  40.              END;
  41.  
  42.   TimeType = RECORD
  43.          Year, Month, Day, Hours, Mins, Secs: CARDINAL
  44.   END;
  45.  
  46. PROCEDURE IOresult() : CARDINAL;
  47.     (* Returns value saved in hidden IOR variable.
  48.        Possible values are:
  49.          2: file not found.
  50.          3: path not found.
  51.          4: too many open files.
  52.          5: access denied (as in writing to a read-only file).
  53.          6: invalid handle.
  54.         12: invalid access.
  55.         15: invalid drive.
  56.         16: trying to remove current directory.
  57.         17: trying to move a file to a different drive or device.
  58.      *)
  59.  
  60. (* These procedures set IOresult if they fail: *)
  61. PROCEDURE Create(Name: ARRAY OF CHAR) : Handle;
  62.     (* Creates file with specified name *)
  63.     (* If unsuccessful, returns MAX(CARDINAL) *)
  64.     (* Possible errors: 3, 4, 5 *)
  65.  
  66. PROCEDURE Open (Name: ARRAY OF CHAR; Typ: AccessType ) : Handle;
  67.     (* Opens existing file with specified name and access type *)
  68.     (* If unsuccessful, returns MAX(CARDINAL) *)
  69.     (* Possible errors: 2, 4, 5, 12 *)
  70.  
  71. PROCEDURE Close (F: Handle): BOOLEAN;
  72.     (* Closes file with specified handle *)
  73.     (* If unsuccessful, returns FALSE *)
  74.     (* Possible error: 6 *)
  75.  
  76. PROCEDURE Read (F: Handle; VAR Buf: ARRAY OF BYTE; Count: CARDINAL) : CARDINAL;
  77.     (* Returns the number of bytes read from file into Buf, up to a maximum *)
  78.     (* of Count. Example: Result = Read( fi, readbuf, SIZE (readbuf) ); *)
  79.     (* If unsuccessful, returns 0 *)
  80.     (* Possible errors: 5, 6 *)
  81.  
  82. PROCEDURE Write (F: Handle; Buf: ARRAY OF BYTE; Count: CARDINAL): CARDINAL;
  83.     (* Returns the number of bytes written to file from Buf, up to a maximum *)
  84.     (* of Count. Example: Result = Write( fi, writebuf, SIZE (writebuf) ); *)
  85.     (* If unsuccessful, returns 0 *)
  86.     (* Possible errors: 5, 6 *)
  87.  
  88. PROCEDURE Rename(Name,NewName : ARRAY OF CHAR): BOOLEAN;
  89.     (* Renames file Name to NewName *)
  90.     (* Can also be used to move a file betwen directories *)
  91.     (* If unsuccessful, returns FALSE *)
  92.     (* Possible errors: 2, 5, 17 *)
  93.  
  94. PROCEDURE SetFileAttribute(atr: FileAttr; Name: ARRAY OF CHAR): BOOLEAN;
  95.     (* Gives named file a new attribute *)
  96.     (* If unsuccessful, returns FALSE *)
  97.     (* Possible errors: 3, 5 *)
  98.  
  99. PROCEDURE GetFileAttribute(Name: ARRAY OF CHAR): FileAttr; 
  100.     (* Returns the attribute of named file *)
  101.     (* If unsuccessful, returns FileAttr{ioerror} *)
  102.     (* Possible errors: 3, 5 *)
  103.  
  104. PROCEDURE Erase (Name: ARRAY OF CHAR): BOOLEAN;
  105.     (* Erases named file *)
  106.     (* If unsuccessful, returns FALSE *)
  107.     (* Possible errors: 2, 5 *)
  108.  
  109. PROCEDURE RmDir (Name: ARRAY OF CHAR): BOOLEAN;
  110.     (* Removes named directory *)
  111.     (* If unsuccessful, returns FALSE *)
  112.     (* Possible errors: 3, 5, 16 *)
  113.  
  114. PROCEDURE MkDir (Name: ARRAY OF CHAR): BOOLEAN;
  115.     (* Creates named directory *)
  116.     (* If unsuccessful, returns FALSE *)
  117.     (* Possible errors: 3, 5 *)
  118.  
  119. PROCEDURE ChDir (Name: ARRAY OF CHAR): BOOLEAN;
  120.     (* Changes from current directory to named directory *)
  121.     (* If unsuccessful, returns FALSE *)
  122.     (* Possible errors: 3 *)
  123.  
  124. PROCEDURE Seek  (F: Handle; Pos: LONGCARD; VAR OK: BOOLEAN);
  125.     (* Points MS-DOS read-write pointer to Pos *)
  126. PROCEDURE SeekRel  (F: Handle; Pos: LONGINT; VAR OK: BOOLEAN);
  127.     (* Mpves MS-DOS read-write pointer Pos bytes toward end of file *)
  128. PROCEDURE GetPos(F: Handle; VAR OK: BOOLEAN) : LONGCARD;
  129.     (* Returns position of MS-DOS read-write pointer *)
  130. PROCEDURE SeekEOF (F: Handle; VAR OK: BOOLEAN);
  131.     (* Moves MS-DOS read-write pointer to end of file *)
  132.     (* For above 3 procedures, possible error: 6 *)
  133. PROCEDURE EOF(F:Handle; VAR OK: BOOLEAN): BOOLEAN;
  134.     (* TRUE if MS-DOS read-write pointer is at end of file *)
  135.     (* Possible errors: 5, 6, 13 *)
  136.     (* Above four procedures return OK if successful *)
  137.  
  138. PROCEDURE Truncate(F: Handle): BOOLEAN;
  139.     (* Truncates file at current MS-DOS read-write pointer position *)
  140.     (* If unsuccessful, returns FALSE *)
  141.     (* Possible errors: 5, 6 *)
  142.  
  143. PROCEDURE SetFileTime(fi: Handle; filetime: LONGCARD): BOOLEAN;
  144.     (* Sets the file time to MS-DOS format value in filetime. *)
  145.     (* See EncodeFileTime below *)
  146.     (* Returns false if unsucessful *)
  147.     (* Possible error: 6 *)
  148.  
  149. PROCEDURE FileTime(fi: Handle) : LONGCARD;
  150.     (* Returns the file time in MS-DOS format *)
  151.     (* See DecodeFileTime below *)
  152.     (* Returns 0 if unsucessful *)
  153.     (* Possible error: 6 *)
  154.  
  155. PROCEDURE SetDrive(Dr :SHORTCARD): BOOLEAN;
  156.     (* Selects a new default drive *)
  157.     (* A: = 1, etc. *)
  158.     (* Possible error: 15 *)
  159.  
  160. (* These procedures do not set IOresult *)
  161. PROCEDURE GetDrive():SHORTCARD;
  162.     (* Returns the current default drive *)
  163.     (* A: = 1, etc. *)
  164.  
  165. PROCEDURE Drives(): SHORTCARD;
  166.     (* tells how many *)
  167.  
  168. PROCEDURE GetDir(Drive: SHORTCARD; VAR Name: ARRAY OF CHAR);
  169.     (* Returns the current directory path *)
  170.     (* If invalid drive or if root directory Name = '' *)
  171.  
  172. PROCEDURE VerifyIsOn(): BOOLEAN;
  173.     (* Reports if the MS-DOS write-verify switch is on *)
  174.  
  175. PROCEDURE SetVerify(On: BOOLEAN);
  176.     (* Turns the MS-DOS write-verify switch on (TRUE) or off (FALSE) *)
  177.  
  178. PROCEDURE DecodeFileTime ( filetime: LONGCARD; VAR T: TimeType );
  179.     (* Translates MS-DOS format filetime into TimeType, *)
  180.     (* so you and your program can read it *)
  181.     (* See FileTime above *)
  182.  
  183. PROCEDURE EncodeFileTime ( T: TimeType ) : LONGCARD;
  184.     (* Translates TimeType into MS-DOS file time format *)
  185.     (* See SetFileTime above *)
  186.  
  187. PROCEDURE ReadFirstEntry(DirName : ARRAY OF CHAR;
  188.                          Attr    : FileAttr;
  189.                          VAR D   : DirEntry) : BOOLEAN;
  190.     (* Returns information on first file found matching *)
  191.     (* DirName (which may include wildcards) in D.      *)
  192.     (* Will return hidden and system files and directories *)
  193.     (* if they are included in Attr.  Returns FALSE if no *)
  194.     (* matching file is found. See ReadNextEntry. *)
  195.  
  196. PROCEDURE ReadNextEntry (VAR D   : DirEntry) : BOOLEAN;
  197.     (* Returns subsequent matching files after first is *)
  198.     (* found by ReadFirstEntry, above. Returns FALSE if no *)
  199.     (* matching file is found. *)
  200.  
  201. PROCEDURE SetDTA( D : ADDRESS );
  202.     (* Assigns the MS-DOS disk transfer area to ADDRESS *)
  203.  
  204. PROCEDURE GetDTA(): ADDRESS;
  205.     (* Returns address of MS-DOS disk transfer area *)
  206.  
  207. PROCEDURE DiskFree(dr: SHORTCARD; VAR BytesPerClust : CARDINAL ): LONGCARD;
  208.     (* Returns disk free space in bytes.  BytesPerCluster returns *)
  209.     (* the smallest increment of disk space that can be allocated. *)
  210.     (* Thus a one-bit file will require BytesPerCluster bytes. *)
  211.  
  212. END FioAsm.
  213.